﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace masini
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                CarsFactory fabrica;
                Client _client = new Client();
                Console.Write("Dati numele clientului: ");
                string nume_client = Console.ReadLine();
                Console.Write("Dati varsta clientului: ");
                int varsta_client = System.Convert.ToInt32(Console.ReadLine());
                _client = new Client(nume_client, varsta_client);


                while (true)
                {
                    Console.WriteLine("\n\n-----Meniu------");
                    Console.WriteLine("1. Adauga masini in lista clientului");
                    Console.WriteLine("2. Vizualizeaza lista de masini a clientului");
                    Console.WriteLine("3. Sterge o masina din lista clientului");
                    Console.WriteLine("0. Iesire program");
                    Console.Write("Optiunea este: ");

                    int opt = System.Convert.ToInt32(Console.ReadLine());
                    if (opt == 1)
                    {
                        Console.Write("Dati numele masinii: (bmw,mercedes,audi) ");
                        string nume_masina = Console.ReadLine();

                        Console.Write("Dati tipul masinii: (sedan/coupe/mini) ");
                        string tip_masina = Console.ReadLine();

                        if (tip_masina == "sedan")
                        {
                            fabrica = SedanPool.Instance();
                            _client.addCar(fabrica.SearchByName(nume_masina, true));
                        }
                        if (tip_masina == "coupe")
                        {
                            fabrica = SedanPool.Instance();
                            _client.addCar(fabrica.SearchByName(nume_masina, true));
                        }
                        if (tip_masina == "mini")
                        {
                            fabrica = MiniPool.Instance();
                            _client.addCar(fabrica.SearchByName(nume_masina, true));
                        }

                    }
                    if (opt == 2)
                    {
                        _client.printCars();
                    }
                    if (opt == 3)
                    {
                        if (_client.removeCar() == 1)
                            Console.WriteLine("Prima masina a clientului a fost stearsa din lista");
                    }
                    if (opt == 0)
                        Environment.Exit(0);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("S-a intalnit o eroare");
            }

        }
    }
}
